package com.example.qxfw.qxxx.service.impl;

import com.example.qxfw.common.entity.xt.ContourSetting;
import com.example.qxfw.common.mapper.ContourSettingMapperXml;
import com.example.qxfw.common.util.ByteToFileUtil;
import com.example.qxfw.qxxx.dto.EqualLine;
import com.example.qxfw.qxxx.service.RefinedForecastingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/8/15  星期二   10:56
 * @description : 精细化预报业务层实现
 ***************************************/
@Service
public class RefinedForecastingServiceImpl implements RefinedForecastingService {

    @Autowired
    private ContourSettingMapperXml contourSettingMapperXml;

    @Autowired
    private ByteToFileUtil byteToFileUtil;

    @Override
    public List<ContourSetting> queryByElementType(final String elementType) {
        return contourSettingMapperXml.queryByElementType(elementType);
    }

    /************************
     * @Description :等值线
     * @param list : List<ContourSetting>
     * @return : java.util.List<com.example.demo.qxxx.dto.EqualLine>
     ************************/

    @Override
    public List<EqualLine> equalLineList(final List<ContourSetting> list) {
        final Integer[] i = {1};
        List<EqualLine> elList = new ArrayList<>();
        list.forEach(contourSetting -> {
            EqualLine equalLine = new EqualLine();
            equalLine.setStrElement(i[0].toString());
            equalLine.setdValue(Float.parseFloat(contourSetting.getElementvalue().toString()));
            equalLine.setiColor(contourSetting.getElementcolor());
            elList.add(equalLine);
            i[0]++;
        });
        return elList;
    }

}
